package com.charging.service.impl;

import com.charging.dao.ChargingPileDao;
import com.charging.entity.ChargingPile;
import com.charging.service.ChargingPileService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class ChargingPileServiceImpl implements ChargingPileService {

    @Resource
    private ChargingPileDao chargingPileDao;

    @Override
    public List<ChargingPile> findAll() {
        return chargingPileDao.findAll();
    }

    @Override
    public ChargingPile findById(Long id) {
        return chargingPileDao.findById(id);
    }

    @Override
    public void add(ChargingPile pile) {
        chargingPileDao.insert(pile);
    }

    @Override
    public void update(ChargingPile pile) {
        pile.setUpdateTime(new Date());
       chargingPileDao.update(pile);
    }

    @Override
    public void delete(Long id) {
        chargingPileDao.delete(id);
    }

    @Override
    public List<ChargingPile> getPilesInMapRange(Double minLat, Double maxLat, Double minLng, Double maxLng) {
        return chargingPileDao.selectByLocationRange(minLat, maxLat, minLng, maxLng);
    }

    @Override
    public List<ChargingPile> getAllPileLocations() {
        return chargingPileDao.selectAllLocations();
    }

    @Override
    // 基础统计：总充电桩数
    public long getTotalPileCount() {
        return chargingPileDao.count();
    }

    @Override
    public int countAvailablePiles() {
        return chargingPileDao.countAvailablePiles();
    }


    @Override
    public ChargingPile getPileById(Long pileId) {
        return null;
    }

    @Override
    public void updatePileStatus(Long pileId, String available) {

    }
}
